package com.wnxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.mapper.UserMapper;
import com.wnxy.pojo.User;
import com.wnxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> findByPage(Integer current, Integer size) {
        // 开启分页支持，其后第一条自动分页
        PageHelper.startPage(current,size);
        // 分页查询的sql
        List<User> list = userMapper.findAll();
        // 返回分页对象
        return new PageInfo<>(list);
    }
}
